package com.hxh.service;

import com.baomidou.mybatisplus.plugins.Page;
import com.hxh.dao.ProjectDetailDao;
import com.hxh.entity.ProjectDetail;
import com.hxh.entity.input.ProjectDetailInput;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import javax.annotation.Resource;
import java.util.List;


@Service
@Transactional
@Slf4j
public class ProjectDetailService {
    @Resource ProjectDetailDao projectDetailDao;



    public int insertList(List<ProjectDetailInput> pojo) {
        if(CollectionUtils.isEmpty(pojo)){
            return 0;
        }

        int res = projectDetailDao.insertList(pojo);
        return res;
    }

    public List<ProjectDetail> select(ProjectDetailInput pojo) {
        return projectDetailDao.select(pojo);
    }

    public boolean deleteById(Integer id){
        return projectDetailDao.deleteById(id) > 0;
    }

    public ProjectDetail selectById(Integer id){
        if(id == null ) {
          return null;
        }
        return projectDetailDao.selectById(id);
    }

    public void listPage(Page<ProjectDetail> page, ProjectDetailInput pojo) {
        page.setRecords(projectDetailDao.listPage(page, pojo));
    }

    public boolean updateSelective(ProjectDetailInput pojo) {

        int res = projectDetailDao.updateSelective(pojo);
        return res > 0;
    }

}
